package cn.andy.android.crm.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.andy.android.crm.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class SettingsFragment extends Fragment {
	
	private static String[] settings = new String[]{"Settings"};
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		View view = inflater.inflate(R.layout.fragment_settings, container, false);
		
		ListView listView = (ListView) view.findViewById(R.id.settingsList);
		
//		List<Map<String, String>> settingslist = new ArrayList<Map<String, String>>();
//		Map<String, String> map = new HashMap<String, String>();
//		map.put("ItemTitle", getString(R.string.tab_settings_general));
//		settingslist.add(map);
		
		Activity activity = getActivity();
//		listView.setAdapter(new SimpleAdapter(activity, settingslist, R.layout.simple_listitem,
//				new String[]{"ItemTitle"}, new int[]{R.id.ItemTitle}));
		listView.setAdapter(new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, settings));
		
		listView.setOnItemClickListener(new ListView.OnItemClickListener() {

			public void onItemClick(AdapterView<?> lv, View view, int position,
					long id) {
				String activityName = settings[position];
				try {
					Class clazz = Class.forName("cn.andy.android.crm.activity." + activityName);
					Intent intent = new Intent(getActivity(), clazz);
					startActivity(intent);
				} catch (ClassNotFoundException e) {
					e.printStackTrace();
				}
			}
		});
		return view;
	}

}
